package com.wqc.springbootmydatis.controller;

import com.wqc.springbootmydatis.pojo.User;
import com.wqc.springbootmydatis.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {

    @Autowired
    private UserService userService;
    @RequestMapping("/findById")
    public User findById(Integer id){
        try {
            System.out.println("查询用户ID: " + id);
            if (id == null) {
                System.out.println("ID参数为空");
                return null;
            }
            User user = userService.findById(id);
            System.out.println("查询结果: " + user);
            return user;
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
    }

}
